#!/usr/bin/perl

use strict;
use warnings;
require 'forum_common.pl';

connect_to_database() or bad_deal();

record_this_hit();

print	header($forum::http_header),
		forum_start(forum_cpanel(get_current_user(get_sess_id())));

my $content = param('fakecontent');
$content = as_post($content) if (defined $content);
my $textarea = textarea(-name=>'fakecontent', -cols=>75, -rows=>15,
						-style=>'width:99%;height:256px');

print <<HTML;
<p>
MBCode is very simple to understand. It is also very powerful because
it can theoretically do anything CSS can do. Because of this, you may
need to have some CSS knowledge. However, if you do not know any CSS
at all, I will teach you some basics here so that you can get started
adding colors and fonts to your posts quickly and easily. If you want
to learn more CSS, there are TONS of tutorials out there, all ranging
from beginner to advanced. I suggest you take a look at some of them,
because not only will you be able to use what you have learned here,
but CSS is also a good skill to have if you ever want to get into any
kind of web design.
</p>
<!--
<div style="padding:0.5em 1em;border:solid white 1px;background-color:#222">
<p>
MBCode was written using something called Regular Expressions (or regex
for short). If you don't know what that is, then feel free to skip this
here block, beacuse you won't understand it, and it isn't necessary for
learning MBCode. However, it will be helpful if you do know regexes, so
if you do, read on. Hopefully, this will be the only thing you need to
read to be able to start using MBCode.
</p>

<p>
First of all, if you know perl, regexes, and CSS pretty well already, and
if you are good and reading code and understanding what it does, then all
you have to read is this next subroutine, and you should understand how
MBCode works:
<code>
sub mbcode
{
	\$str = shift;
	while (\$str =~ s/\\[([\\w\\s\\-]+:[^\\[\\]:;]+(?:;[\\w\\s\\-]+:[^\\[\\]:;]+)*)\\]([^\\[]*)\\[\\/\\]/&lt;span style="\$1"&gt;\$2&lt;\\/span&gt;/)
	{}
	return \$str;
}
</code>

</p>

<p>
paragraph 3
</p>

</div>
-->
<p>
Quick examples:
</p>
HTML
my @exs = ();
$exs[0] = '[color:red]This is red![/]';
$exs[1] = '[color:#cc0;background-color:#400;font-size:large]Multi-styled![/]';
$exs[2] = '[color:lime]Example of [font-style:italic]nested[/] tags[/]';
$exs[3] = '{link:http://www.google.com}';
$exs[4] = '{link:http://pocketfire.net|Pocketfire!}';
$exs[5] = '{img:http://pocketfire.net/doesnt_exist.gif|alt-text|title}';
print '<table border="1" class="divcalign">';
print Tr(td({-style=>'padding:0.5em'},[as_post($_),escapeHTML($_)])) for @exs;
print '</table>', <<HTML;
<div style="padding-top:4em">
<form action="#preview" method="post" enctype="application/x-www-form-urlencoded">
<div class="ftable"><div class="ftr">
<div class="ftd calign" style="width:50%">
	$textarea
	<br />
	<input type="submit" name="submit" value="Preview" />
</div>
<a id="preview"></a>
<div class="ftd" style="width:50%;vertical-align:top">
	<div id="post_content" class="postc content" style="border:solid blue 1px;height:256px;overflow:auto;padding:2px">$content</div>
</div>
</div></div>
</form>
</div>

HTML

gameover:
print forum_end();
forum_disconnect();
